import collections
class Solution(object):
    def maxFreq(self, s, maxLetters, minSize, maxSize):
        n = len(s)
        d = collections.defaultdict(int)
        for k in range(minSize, maxSize + 1):
            for i in range(n - k + 1):
                if len(set(s[i:i + k])) <= maxLetters:
                    d[s[i:i + k]] += 1
        if not d:
            return 0
        return max(d.values())


